mui.init({
	swipeBack: true
});
/**
 * 当点击首页是调用“刷新”事件
 */
window.addEventListener('reload', function(event) {
	//loadProjectDatas();
});

mui.plusReady(function() {
	plus.storage.removeItem(KeyCfg.slideNumber); /*页面加载时，清除当前Tab 选项卡索引号，以便默认显示的是借款标*/

	//	不同分辨率手机按比例显示
	var height1 = $(window).height() * 0.11 + "px"; //来理财标题
	$(".mui-home-head").css("height", height1);

	var height4 = $(window).height() * 0.018 + "px"; //来理财标题logo
	$(".mui-home-head img").css("padding-top", height4);

	var height6 = $(window).height() * 0.10 + "px"; //来理财标题logo
	$(".mui-home-head img").css("height", height6);

	var height10 = $(window).height() * 0.41 + "px"; //滚动图片DIV 大小
	$(".pic_scroll").css("height", height10);

	var height7 = $(window).height() * 0.31 + "px"; //滚动图片大小 
	$(".pic_scroll img").css("height", height7);

	$(".pic_scroll").css("padding-top", height1);

	var height3 = $(window).height() * 0.588 + "px"; //四宫格
	$(".mui-home-body").css("height", height3);

	var height5 = $(window).height() * 0.296 + "px"; //四宫格中的小格格
	$(".lcy-mui-col-xs-4").css("height", height5);

	var height8 = $(window).height() * 0.10 + "px"; //四宫格小图标
	$(".mui-yuelibao-logo img").css("height", height8);

	var height9 = $(window).height() * 0.05 + "px"; //四宫格字体间距
	$(".lcy-mui-col-xs-4").css("line-height", height9);


});





//
//(function(){
//	var url = UrlConfig.index_banners;  
//    $.ajax(url, {  
//      data: {  
//        'dtype': 'jsonp',  
//        '_': new Date().getTime()  
//      },  
//      dataType: 'jsonp',  
//      crossDomain: true,  
//      success: function(data) {
//    		loadBanners(data);
//    		/*------ 滚动图片自动播放代码 CODE START -----*/
//			var slider = mui("#slider");
//			slider.slider({interval: 5000});
//			//loadProjectDatas();
//      }
//    });
//	function loadBanners(data){
//		data = JSON.parse(data);
//		var sliderEle = $("#pic_scroll");
//		sliderEle.empty();
//		var imgData =  data[data.length-1];
//		var arr = [];
//		arr[arr.length] =  getBannerHtml(imgData,"mui-slider-item-duplicate");
//		for(var i=0,count=data.length; i<count; i++){
//			imgData = data[i];
//			var html = getBannerHtml(imgData);
//			arr[arr.length] = html;
//		}
//		imgData = data[0];
//		arr[arr.length] =  getBannerHtml(imgData,"mui-slider-item-duplicate");
//		var bannerHtml = arr.join("");
//		var b_arr = [
//			'<div id="slider" class="mui-slider">',
//			'<div class="mui-slider-group mui-slider-loop">',
//			bannerHtml,
//			'</div>',
//			'<div class="mui-slider-indicator">',
//			'	<div class="mui-indicator mui-active"></div>',
//			'	<div class="mui-indicator"></div>',
//			'	<div class="mui-indicator"></div>',
//			'	<div class="mui-indicator"></div>',
//			'</div>',
//			'</div>'
//		];
//		sliderEle.html(b_arr.join(" "));
//	}
//	
//	function getBannerHtml(imgData,cls){
//		var imgUrl = imgData.imgUrl;
//		imgUrl = SERVER_BASEURL+imgUrl;
//		var height7 = $(window).height()*0.31+"px";
//		if(!cls) cls = "";
//		var arr = [
//			'<div class="mui-slider-item '+cls+'">',
//			'	<a href="#">',
//			'	<img style="height:'+height7+'" src="'+imgUrl+'">',
//			'	</a>',
//			'</div>'
//		];
//		return arr.join(" ");
//	}
//})();
	/*------ 滚动图片自动播放代码 CODE END -----*/

/*------ Tab选项卡代码 CODE START -----*/
var IdMgr = {
	/**
	 * 新标购买按钮前缀
	 */
	btnLoanIdPrefix: 'btnLoan_',
	/**
	 * 债权转让按钮前缀
	 */
	btnTransferIdPrefix: 'btnTransfer_',
};


function plusReady(fn) {
	if (window.plus) {
		fn();
	} else {
		document.addEventListener('plusready', fn, false);
	}
}




mui(".mui-content ").on("tap", "a", function() {
	var targetPageId = plus.webview.currentWebview().id;
	plus.storage.setItem(KeyCfg.targetPageId, targetPageId);
	var self = this;
	var name = $(self).attr("id");
	switch (name) {
		case 'yuelibao':
			plus.webview.currentWebview().parent().evalJS("activeTabItemPage('invest');");
			break;
		case 'moneychange':
			plus.webview.currentWebview().parent().evalJS("activeTabItemPage('invest','1');");
			break;
		case 'auto_tender':
			MuiEventMgr.checkSecuityForwad(function() {
				openPage('../automatic/autoBid.html', {});
			});
			break;
		case '':
			MuiEventMgr.checkSecuityForwad(function() {
				openPage('../share/share.html', {});
			});
			break;

	}
});

function openPage(url, pars) {
	if (!pars) pars = {};
	var cfg = {
		pars: pars
	};
	MuiEventMgr.openBySafe(url, cfg);
}